<Page x:Class="CAION2.Views.IdianPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:classes="clr-namespace:CAION2.Classes"
      xmlns:mui="clr-namespace:FirstFloor.ModernUI.Windows.Controls;assembly=FirstFloor.ModernUI"
      xmlns:resources="clr-namespace:CAION2.Properties"
      xmlns:viewModels="clr-namespace:CAION2.ViewModels">

    <Page.Resources>
        <viewModels:ItemTypeColorConverter x:Key="ItemTypeColorConverter" />
        <viewModels:IdianRandomTextConverter x:Key="IdianRandomTextConverter" />
    </Page.Resources>

    <Page.DataContext>
        <viewModels:IdianDialogViewModel />
    </Page.DataContext>

    <Grid Style="{StaticResource ContentRoot}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="60" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Image Width="40"
               Height="40"
               HorizontalAlignment="Left"
               Source="{Binding Idian.Icon}" />
        <mui:BBCodeBlock Grid.Row="0" Grid.ColumnSpan="2" Grid.Column="0"
                   Margin="50,0,0,0"
                   VerticalAlignment="Center"
                   FontSize="14"
                   Foreground="{Binding Idian.Quality,
                                        Converter={StaticResource ItemTypeColorConverter}}"
                   BBCode="{Binding IdianText}" >
            <mui:BBCodeBlock.Effect>
                <DropShadowEffect BlurRadius="1"
                                      Direction="315"
                                      Opacity="0.7"
                                      ShadowDepth="1"
                                      Color="Black" />
            </mui:BBCodeBlock.Effect>
        </mui:BBCodeBlock>

        <mui:ModernButton Grid.Row="0" Grid.Column="1"
                          HorizontalAlignment="Right"
                          VerticalAlignment="Center"
                          Command="{Binding DeleteIdianCommand}"
                          IconData="{StaticResource ClearIcon}"
                          ToolTip="{x:Static resources:Resources.Idian_DeleteIdian}" />

        <StackPanel Grid.Row="1"
                    Grid.ColumnSpan="2" Grid.Column="0"
                    Margin="0,0,0,10"
                    VerticalAlignment="Bottom"
                    Orientation="Horizontal">
            <RadioButton Margin="3"
                         Command="{Binding SelectQualityCommand}"
                         CommandParameter="rare"
                         Content="{x:Static resources:Resources.Items_Rare}"
                         Foreground="#FF48C23F" />
            <RadioButton Margin="3"
                         Command="{Binding SelectQualityCommand}"
                         CommandParameter="legend"
                         Content="{x:Static resources:Resources.Items_Legend}"
                         Foreground="#FF00ADEF" />
            <RadioButton Margin="3"
                         Command="{Binding SelectQualityCommand}"
                         CommandParameter="unique"
                         Content="{x:Static resources:Resources.Items_Unique}"
                         Foreground="#FFFFCC00" />
            <RadioButton Margin="3"
                         Command="{Binding SelectQualityCommand}"
                         CommandParameter="epic"
                         Content="{x:Static resources:Resources.Items_Epic}"
                         Foreground="#FFF79646" />
        </StackPanel>

        <ListBox Grid.Row="2" Grid.Column="0"
                 Width="250"
                 MaxHeight="300"
                 VerticalAlignment="Stretch"
                 VerticalContentAlignment="Stretch"
                 IsSynchronizedWithCurrentItem="True"
                 ItemsSource="{Binding GroupIdians}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 ScrollViewer.VerticalScrollBarVisibility="Auto"
                 SelectedItem="{Binding SelectedGroupIdian,
                                        Mode=TwoWay,
                                        UpdateSourceTrigger=PropertyChanged}">
            <ListBox.ItemTemplate>
                <DataTemplate DataType="{x:Type classes:Idian}">
                    <StackPanel Height="32"
                                Margin="0,4"
                                Orientation="Horizontal">
                        <Image Width="28"
                               Height="28"
                               VerticalAlignment="Center"
                               Source="{Binding Icon}"
                               Stretch="Uniform" />
                        <mui:BBCodeBlock Width="210"
                                   Margin="3,0,0,0"
                                   VerticalAlignment="Center"
                                   Foreground="{Binding Quality,
                                                        Converter={StaticResource ItemTypeColorConverter}}"
                                   BBCode="{Binding Translate}"
                                   TextWrapping="Wrap" >
                            <mui:BBCodeBlock.Effect>
                                <DropShadowEffect BlurRadius="1"
                                      Direction="315"
                                      Opacity="0.7"
                                      ShadowDepth="1"
                                      Color="Black" />
                            </mui:BBCodeBlock.Effect>
                        </mui:BBCodeBlock>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <ListBox Grid.Row="2"
                 Grid.Column="1"
                 Width="600"
                 MaxHeight="300"
                 Margin="10,0,0,0"
                 VerticalAlignment="Stretch"
                 VerticalContentAlignment="Stretch"
                 IsSynchronizedWithCurrentItem="True"
                 ItemsSource="{Binding Idians}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 ScrollViewer.VerticalScrollBarVisibility="Auto"
                 SelectedItem="{Binding SelectedIdian,
                                        Mode=TwoWay,
                                        UpdateSourceTrigger=PropertyChanged}">
            <ListBox.ItemTemplate>
                <DataTemplate DataType="{x:Type classes:Idian}">
                    <WrapPanel Orientation="Horizontal">
                        <TextBlock Width="50"
                                   Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   Text="{Binding Chance}" />
                        <mui:BBCodeBlock Width="150"
                                   Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random1,
                                                  Converter={StaticResource IdianRandomTextConverter}}"
                                   TextWrapping="Wrap" />
                        <mui:BBCodeBlock Width="150"
                                   Margin="15,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random2,
                                                  Converter={StaticResource IdianRandomTextConverter}}"
                                   TextWrapping="Wrap" />
                        <mui:BBCodeBlock Width="150"
                                   Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random3,
                                                  Converter={StaticResource IdianRandomTextConverter}}"
                                   TextWrapping="Wrap" />
                        <mui:BBCodeBlock Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random4,
                                                  Converter={StaticResource IdianRandomTextConverter}}" />
                        <mui:BBCodeBlock Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random5,
                                                  Converter={StaticResource IdianRandomTextConverter}}" />
                        <mui:BBCodeBlock Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random6,
                                                  Converter={StaticResource IdianRandomTextConverter}}" />
                        <mui:BBCodeBlock Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random7,
                                                  Converter={StaticResource IdianRandomTextConverter}}" />
                        <mui:BBCodeBlock Margin="5,0,2,0"
                                   VerticalAlignment="Center"
                                   BBCode="{Binding Random8,
                                                  Converter={StaticResource IdianRandomTextConverter}}" />
                    </WrapPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

    </Grid>

</Page>
